<template>
  <div class="headerBox">
    <header>
      <div class=" fix fixR">
        <div class="">
          <div class=" fix">
            <div class=" fix">
              <div class="imgBox">
                <img :src="usermes.avatar">
              </div>
              <div class="userName  ">
                <div class="dropdown  ">
                  <button class=" btn btn-default dropdown-toggle suer" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{usermes.name}}
                    <span class="caret"></span>
                  </button>
                  <ul class="dropdown-menu " aria-labelledby="dropdownMenu2">
                    <li><a @click="logout">退出登录</a></li>
                    <li><a href="javascript:;">修改密码</a></li>
                  </ul>
                </div>
              </div>
              <div class="iconBox  relative" >
                <img :src="massge.icon">
                <i> 1</i>
              </div>
              <div class="text">
                <p><a href="javascript:;" class="goHelp"> 帮助中心  </a></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </header>
  </div>

</template>
<script>
    import massgeIcon from '../../assets/massg.png';
    import userMag from '../../assets/userMage.png';
    export default {
        name: 'CommonHeader',
        created(){
            this.userText();

        },
        data:function() {
            return {
               usermes:{},
                massge: {
                    icon:massgeIcon,
                    cunt:0,
                    list:[]
                },
            };
        },
        methods:{
            //退出登錄
            logout(){
                localStorage.removeItem('access_token');
                this.$router.push({name:'index'})
            },
            // 用戶信息
            userText(){
                var userLocal=JSON.parse(localStorage.getItem('user'))
                var userId=userLocal.userid;
                var url='/api/organization/employees/user/'+userId+'?type=DOCTOR'
                this.$http.get(url).then(function(res){
                    this.usermes=res.body;
                })

            }
        }
    }
</script>
